import scrapy
import sys
reload(sys)
from scrapy.selector import Selector

class DmozItem(scrapy.Item):
    # define the fields for your item here like:
    # name = scrapy.Field()
    title = scrapy.Field()
    link = scrapy.Field()
    desc = scrapy.Field()

class DmozSpider(scrapy.Spider):
    name = 'dmoz'
    allowed_domains = ["5858168.com"]
    start_urls = [
        "http://www.5858168.com/buy/index.asp?page=1"
    ]

    def parse(self, response):

        for dl in response.xpath('//*[@id="BuyList"]'):
            item =DmozItem()
            title = dl.xpath('//*[@id="BuyList"]/dl[1]/dt/h1/a').extract()[0]
            link =dl.xpath('//*[@id="BuyList"]/dl[1]/dt/h1/a/@href').extract()[0]
            desc = dl.xpath('//*[@id="BuyList"]/dl[1]/dt/p/text()').extract()[0]
            item['title'] =title
            item['link']  =link
            item['desc']  =desc
            print title
            yield item
